import axios from 'axios'
import {message as Msg} from 'ant-design-vue'

const serive = axios.create({
  baseURL: '/api',
  timeout: 10000
})

//请求拦截器
serive.interceptors.request.use(
  (config) => {
    
    console.log('请求成功' + config)
    return config
  },
  (error) => Promise.reject(error)
)

//响应拦截器
serive.interceptors.response.use(
  (response) => {
    const {data,status} = response
    console.log('响应成功' + response)
    return data
  },
  (error) => {
    console.log('响应错误' + error)
    Msg.success(error.response.data.msg)
    return Promise.reject(error)
  }
)
export default serive
